#include "pyramid.h"

namespace visualization
{

const size_t Pyramid::facets[16] = {
	0, 1, 2,
	0, 2, 3,
	0, 3, 4,
	0, 4, 1,
	4, 3, 2, 1};
const size_t Pyramid::facet_offsets[5] = { 0, 3, 6, 9, 12 };
const size_t Pyramid::facet_size[5] = { 3, 3, 3, 3, 4};

CellType Pyramid::GetFacet(size_t i, size_t *point_ids)
{
	size_t offset = facet_offsets[i];
	for (size_t j=0; j<facet_size[i]; j++)
		point_ids[j] = facets[offset + j];
	return i == 4 ? QUADRANGEL : TRIANGLE;
}

Point Pyramid::GetBeryCenter() const
{
	Point ret, *cur = 0;

	for (size_t i=0; i<5; i++)
	{
		cur = server->GetPoint(i);
		ret.x += cur->x;
		ret.y += cur->y;
		ret.z += cur->z;
	}

	ret.x /= 5;
	ret.y /= 5;
	ret.z /= 5;

	return ret;
}

}
